package com.ruoyi.platform.system.exception.controller;

import com.ruoyi.base.controller.BaseController;
import com.ruoyi.base.pojo.HttpResult;
import com.ruoyi.base.enums.ExceptionEnum;
import com.ruoyi.base.annotaion.TokenIgnore;
import com.ruoyi.platform.system.exception.pojo.ExceptionCodeDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 异常
 *
 * @author lcf
 */
@Api(value = "异常code", tags = {"异常code"})
@RestController
@RequestMapping("/exception")
public class ExceptionController extends BaseController {

    /**
     * 获取异常码列表
     */
    @ApiOperation("异常码列表")
    @GetMapping("/code/list")
    @TokenIgnore
    public HttpResult<List<ExceptionCodeDTO>> getExceptionCodeList() {
        return data(Arrays.stream(ExceptionEnum.values()).map(ExceptionCodeDTO::new).collect(Collectors.toList()));
    }
}
